package com.ftg.learn.config;

import com.ftg.learn.util.R;
import com.ftg.learn.util.TipUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常化处理类
 * RestControllerAdvice restcontroller的通知功能
 *
 * @author 布衣
 */
@RestControllerAdvice
public class GlobalExceptionConfig {

    /**
     * 运行时异常的全局提示功能
     * @param e  异常
     * @return R<String>
     */
    @ExceptionHandler(RuntimeException.class)
    public R<String> exceptionHandler(RuntimeException e) {
        return R.build(TipUtil.TOKEN_PREFIX_ERROR, e.getMessage());
    }

}
